package collection;

import java.util.HashMap;
import java.util.Map;

/**
 * @author DBX
 * @effect
 * @date 2021/09/06/16:33
 */
public class Test8 {
    public static void main(String[] args) {
        String str = "hello world! i love java!!java yyds";

        char[] c = str.toCharArray();
        Map<Object,Integer> map = new HashMap<>();
        for (int i = 0; i <c.length ; i++) {
            if (map.containsKey(c[i])){
                map.put(c[i],map.get(c[i])+1);
            }else {
                map.put(c[i],1);
            }
        }
        System.out.println(map);
        String[] s =str.split("|");
        for (String s1 : s) {
            map.put(s1,map.containsKey(s1)? map.get(s1)+1:1);
        }
        System.out.println(map);
    }
}
